$(function() {
	$("#kw").on("input", function() {
		$.ajax({
			url: "area/search?kw=" + encodeURIComponent($(this).val()),
			type: "GET",
			dataType: "json"
		}).done(function(response) {
			var tableOp = tableOperator($("#result"), response);
			tableOp.createTable();
		});
	});
	
	function tableOperator(table, data) {
		var obj = {};
		obj.createTable = function() {
			table.empty();
			if (data) {
				data.forEach((item) => {
					table.append($("<tr>").text(item.area));
				});
			}
		}
		return obj;
	}
});